libexpr: diagnostics (warning/error), tags framework#9060
libexpr: diagnostics (warning/error), tags framework#9060inclyc wants to merge 2 commits intoNixOS:masterfrom
Conversation
This is an NFC PR that splits epilogue & prologue from parser. As mentioned in NixOS#8812, we can add static checking tools & auto formatting for these files, but if it is written .y directly, the clang parser cannot understand the code is actually "C++".
inclyc
left a comment
There was a problem hiding this comment.
This PR just takes up an initial approach of adding diagnostics, please design-review the implementation to determine if we can go on :)
|
|
||
| if (res) | ||
| throw ParseError(data.error.value()); | ||
| data.diags.checkRaise(data.state.positions); |
There was a problem hiding this comment.
currently the diagnostic engine will raise exceptions here, for backward compatibility. I think in the future we can pretty print the list of diagnostic
| in | ||
| { | ||
| declarations = '' | ||
| /// Generated from diagnostic-gen.nix |
There was a problem hiding this comment.
- diagnostic-gen.nix
+ diagnostics-gen.nix| } // namespace nix | ||
| ''; | ||
| idmacros = '' | ||
| /// Generated from diagnostic-gen.nix |
| $(d)/diagnostics-id.inc.hh | ||
|
|
||
| $(d)/diagnostics-id.inc.hh: $(d)/diagnostics-gen.nix $(d)/diagnostics.nix | ||
| $(trace-gen) $(nixcmd) --experimental-features "nix-command" eval --raw --file $< idmacros > $@ |
There was a problem hiding this comment.
It seems like there are many problems caused by this line, because we want to open some directories in the sandbox-ed environment, should I do this?
👎 on this, we really don't want a cyclic dependency. (What happens when Also, Nix is not a general purpose language and it's definitely not intended for C++ codegen. Better to use C++ macros or templates. (Haven't looked at the rest of the PR.) |
Thanks, closing. |
Motivation
This is an initial support for warning & diagnostics (it is really large so I pushed it here for review). We talked about Nix language versioning in NixOS/rfcs#137 , and this PR brings some deprecate warnings for nix parser.
Previously we are just throwing exceptions, but it may not work for encountered some syntax we want to give a "warning" to the user, so I deferred the throwing after parsing.
Diagnostic types are generated from
diagnostics.nixdeclaratively and we can maintain such a list with less pain, but it introduces build-time dependency for a workingnix.Context
Depends-on: #9059
How to read the diff
Please skip commits in #9059
Priorities
Add 👍 to pull requests you find important.